import jwt from 'jsonwebtoken';

const secretKey = 'ifrontend.net';

export const signToken = (username: string, expiresIn: string = '1h') => {
  return jwt.sign({ username }, secretKey, { expiresIn });
}

export const verifyToken = (token: string) => {
  try {
    const decoded = jwt.verify(token, secretKey);
    return decoded;
  } catch (err) {
    return null;
  }
}